//
//  SaveScribbleCommand.m
//  Test
//
//  Created by 杨德龙 on 2017/9/24.
//  Copyright © 2017年 ___杨德龙___. All rights reserved.
//

#import "SaveScribbleCommand.h"
#import "CoordinatingController.h"
#import "CanvasViewController.h"
#import "ScribbleManager.h"
#import "UIView+UIImage.h"    // 转换

@implementation SaveScribbleCommand

- (void)execute
{
    // get a hold of all necessary information
    CoordinatingController *coordinatingController = [CoordinatingController sharedInstance];
    CanvasViewController *canvasViewController = [coordinatingController canvasViewController];
    // 讲canvasView 转换成   image
    UIImage *canvasViewImage = [[canvasViewController canvasView] image];
    Scribble *scribble = [canvasViewController scribble];
    
    //
    ScribbleManager *scribbleManager = [[ScribbleManager alloc] init];
    [scribbleManager saveScribble:scribble thumbnail:canvasViewImage];
    
    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Your Scribble has saved" message:@"Hello this is DeLong" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:@"Cancle", nil];
    [alertView show];
    
}


@end













